﻿using CTP.CRM.Core.Prometheus.Custom;
using Prometheus;

namespace CTP.CRM.Core.Prometheus
{
    public static class PrometheusStartupExtensions
    {
        public static IServiceCollection AddPrometheusMetricsHub(this IServiceCollection services, Action<PrometheusMetricsHub> buildAction)
        {
            PrometheusMetricsHub prometheusMetricsHub = new PrometheusMetricsHub();
            buildAction(prometheusMetricsHub);
            services.AddSingleton(prometheusMetricsHub);
            return services;
        }

        public static IApplicationBuilder UsePrometheus(this IApplicationBuilder app)
        {
            app.UseMetricServer();
            app.UseHttpMetrics();
            return app;
        }
    }
}
